package com.qdaily.ui.ui.viewholder;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.qdaily.supportlibrary.util.ImageUtil;
import com.qdaily.supportlibrary.views.list.ViewHolderBase;
import com.qdaily.ui.R;
import com.qdaily.ui.net.model.ArticleMeta;
import com.qdaily.ui.util.QDUtil;

/**
 * 搜索结果页。
 * Created with IntelliJ IDEA.
 * User: Felix
 * Date: 4/7/15
 * Time: 00:16
 * QQ:74104
 * Email:lovejiuwei@gmail.com
 */
public class SearchResultViewHolder extends ViewHolderBase<ArticleMeta> {
    private ImageView cubeImageViewSearchResultLogo;
    private android.widget.TextView textViewSearchItemLabel;
    private android.widget.TextView textViewSearchItemAuthor;
    private android.widget.TextView textViewSearchItemDate;
    private android.widget.TextView textViewSearchResultTitle;
    private android.widget.TextView textViewSearchResultContent;

    @Override
    public View createView(LayoutInflater layoutInflater) {
        View v = layoutInflater.inflate(R.layout.view_search_result_item, null);
        this.textViewSearchResultContent = (TextView) v.findViewById(R.id.textViewSearchResultContent);
        this.textViewSearchResultTitle = (TextView) v.findViewById(R.id.textViewSearchResultTitle);
        this.textViewSearchItemDate = (TextView) v.findViewById(R.id.textViewSearchItemDate);
        this.textViewSearchItemAuthor = (TextView) v.findViewById(R.id.textViewSearchItemAuthor);
        this.textViewSearchItemLabel = (TextView) v.findViewById(R.id.textViewSearchItemLabel);
        this.cubeImageViewSearchResultLogo = (ImageView) v.findViewById(R.id.cubeImageViewSearchResultLogo);
        return v;
    }

    @Override
    public void showData(int position, ArticleMeta itemData) {
        ImageUtil.getInstance().displayImage(itemData.getPost().getCategory().getImage_small(), cubeImageViewSearchResultLogo);
        textViewSearchItemLabel.setText(itemData.getPost().getCategory().getTitle());
        textViewSearchItemAuthor.setText(itemData.getAuthor().getName());
        textViewSearchItemDate.setText(QDUtil.getSocialDateDisplay(itemData.getPost().getPublish_time()));
        textViewSearchResultTitle.setText(itemData.getPost().getTitle());
        textViewSearchResultContent.setText(itemData.getPost().getDescription());
    }
}